package messages;


/**
 * InvalidMoveMessage
 * 
 * Message sent to the server when some player did an invalid move.
 * An invalid move is one of the following:
 *  - A move for a match that doesn't exist;
 *  - A move for a match where the player isn't one of the participants;
 *  - Am unexpected move made out of order by a player that isn't the next to play;
 *  - An invalid move, according to the specific rules of the game.
 */
public class InvalidMoveMessage extends Message {

	public enum ErrorCode { UnknownMatch, NotAParticipant, NotNextPlayer, UnacceptableMove }
	
	public InvalidMoveMessage(String playerLogin, ErrorCode errorCode, PlayerMoveMessage originalMessage) {
		super();
	
		this.playerLogin = playerLogin;
		this.errorCode = errorCode;
		this.originalMessage = originalMessage;		
	}
		


	public String getPlayerLogin() {
		return this.playerLogin;
	}


	public void setPlayerLogin(String playerLogin) {
		this.playerLogin = playerLogin;
	}
	
	
	public ErrorCode getErrorCode() {
		return this.errorCode;
	}


	public PlayerMoveMessage getOriginalMessage() {
		return this.originalMessage;
	}
	
	
	@Override
	public String toString() {
		return super.toString() + " " + errorCode.toString();
	}
	
	
	private String playerLogin;					// The player who sent the invalid move.
	private ErrorCode errorCode;				// The error code that explains why the move is invalid
	private PlayerMoveMessage originalMessage;	// The original message sent by the player

	private static final long serialVersionUID = 1L;
}
